<!DOCTYPE html>
<html>
<head>
    <title>汽车维修管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
    <div class="container">
        <h1 class="page-title">汽车维修管理系统</h1>
        
        <!-- 导航菜单 -->
        <div class="nav-menu">
            <a href="{{ url_for('orders') }}" class="nav-item">订单管理</a>
            <a href="{{ url_for('customers') }}" class="nav-item">客户管理</a>
            <a href="{{ url_for('vehicles') }}" class="nav-item">车辆管理</a>
            <a href="{{ url_for('parts') }}" class="nav-item">配件管理</a>
            {% if current_user.has_role('admin') %}
            <a href="{{ url_for('users') }}" class="nav-item">用户管理</a>
            {% endif %}
            <a href="{{ url_for('logout') }}" class="nav-item" style="margin-left: auto; background-color: #dc3545;">退出登录</a>
        </div>

        <!-- 基础数据统计 -->
        <div class="section">
            <h2 class="section-title">基础数据统计</h2>
            <div class="stats-grid">
                <div class="stat-card" style="background-color: #e2e3e5;">
                    <h3>客户总数</h3>
                    <p class="stat-number">{{ Customer.query.count() }}</p>
                </div>
                <div class="stat-card" style="background-color: #e2e3e5;">
                    <h3>车辆总数</h3>
                    <p class="stat-number">{{ Vehicle.query.count() }}</p>
                </div>
                <div class="stat-card" style="background-color: #e2e3e5;">
                    <h3>配件种类</h3>
                    <p class="stat-number">{{ Part.query.count() }}</p>
                </div>
                <div class="stat-card" style="background-color: #e2e3e5;">
                    <h3>订单总数</h3>
                    <p class="stat-number">{{ Order.query.count() }}</p>
                </div>
            </div>
        </div>

        <!-- 订单状态看板 -->
        <div class="section">
            <h2 class="section-title">订单状态统计</h2>
            <div class="stats-grid">
                <a href="{{ url_for('orders', status='待维修') }}" class="stat-card-link">
                    <div class="stat-card" style="background-color: #fff3cd;">
                        <h3>待维修</h3>
                        <p class="stat-number">{{ order_stats.pending }}</p>
                    </div>
                </a>
                <a href="{{ url_for('orders', status='维修中') }}" class="stat-card-link">
                    <div class="stat-card" style="background-color: #cce5ff;">
                        <h3>维修中</h3>
                        <p class="stat-number">{{ order_stats.in_progress }}</p>
                    </div>
                </a>
                <a href="{{ url_for('orders', status='已完成') }}" class="stat-card-link">
                    <div class="stat-card" style="background-color: #d4edda;">
                        <h3>已完成</h3>
                        <p class="stat-number">{{ order_stats.completed }}</p>
                    </div>
                </a>
                <a href="{{ url_for('orders', status='已取消') }}" class="stat-card-link">
                    <div class="stat-card" style="background-color: #f8d7da;">
                        <h3>已取消</h3>
                        <p class="stat-number">{{ order_stats.cancelled }}</p>
                    </div>
                </a>
            </div>
        </div>

        <!-- 今日订单 -->
        <div class="section">
            <h2 class="section-title">今日订单</h2>
            <table>
                <thead>
                    <tr>
                        <th>订单号</th>
                        <th>客户名称</th>
                        <th>车牌号</th>
                        <th>状态</th>
                        <th>金额</th>
                        <th>创建时间</th>
                    </tr>
                </thead>
                <tbody>
                    {% for order in today_orders %}
                    <tr>
                        <td>{{ order.order_number }}</td>
                        <td>{{ order.customer.name }}</td>
                        <td>{{ order.vehicle.plate_number }}</td>
                        <td>
                            <span class="status-badge status-{{ order.status }}">{{ order.status }}</span>
                        </td>
                        <td>{{ order.total_amount }}</td>
                        <td>{{ order.created_at.strftime('%H:%M:%S') }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</body>
</html> 